package org.lease.web.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.lease.common.result.Result;
import org.lease.model.entity.UserInfo;
import org.lease.model.enums.BaseStatus;
import org.lease.model.query.UserInfoPageQuery;
import org.lease.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "用户管理")
@RestController
@RequestMapping("/admin/user")
public class UserInfoController {
    @Autowired
    private UserInfoService userInfoService;

    @Operation(summary = "分页条件查询用户信息")
    @GetMapping("/page")
    public Result<IPage<UserInfo>> pageQuery(UserInfoPageQuery query) {
        IPage<UserInfo> page = userInfoService.pageQuery(query);
        return Result.success(page);
    }

    @Operation(summary = "根据 ID 修改用户状态")
    @PostMapping("/updateStatusById")
    public Result updateStatus(Long id, BaseStatus status) {
        userInfoService.updateStatus(id, status);
        return Result.success();
    }
}
